<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Axios使用Post新增数据Restful风格</title>
    <script src="vue.js"></script>
    <script src="axios.min.js"></script>
</head>

<body>
    <div id="app">
        <input type="text" placeholder="请输入部门名称" v-model="dept.deptname">
        <input type="text" placeholder="请输入部门人数" v-model="dept.deptnum">
        <input type="text" placeholder="请输入部门描述" v-model="dept.deptdesc">
        <button @click="addDept">新增部门信息</button>
    </div>
</body>

</html>
<script>
    var vm = new Vue({
        el: "#app",
        data: {
            dept: {
                deptid: "",
                deptname: "",
                deptnum: "",
                deptdesc: ""
            },
           url:"http://localhost:8080/depts"
        },
        methods: {
            addDept(){
                axios.post(this.url,this.dept).then(res=>{
                    console.log(res);
                })
            }

        },
    })
</script>